package com.supermarket.api.web;

import com.supermarket.api.bean.product.ProductDetail;
import com.supermarket.api.common.BaseResponse;
import com.supermarket.api.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 商品接口
 * @author 李其伟
 * @date 2023/10/17
 */
@Controller
@RequestMapping("/product")
public class ProductController {

    /**
     * 商品服务层
     */
    @Autowired
    private ProductService productService;

    @ResponseBody
    @GetMapping("/detail/{sku}")
    public String detail(@PathVariable String sku){
        ProductDetail pd = productService.detail(sku);
        return BaseResponse.successJson(pd);
    }

}
